<?php
	$funcao = 'pow($x,2) - pow($y,2)';
	$ex[0] = 0;
	$ey[0] = 0;
	$int1 = 0;
	$int2 = 1;
	$n = 10;
	
	$output = "";
	$output.="\n<p>y' = ".$funcao."</p>";
	$output.="\n<p>y(".$ex[0].") = ".$ey[0]."</p>";
	$output.="\n<p>Intervalo: [$int1,$int2]";
	$output.="\n<p>N=$n</p>";

	$x = $ex[0];
	$x = $ey[0];
	$eval = "\$result = $funcao;";

	echo $output;

	echo "\n<p>y(".$ex[0].") = ".$ey[0]."</p>";
    $h = ($int2 - $int1) / $n;
	for ($i = 0; $i < $n; $i++)
	{
        $x = $ex[$i];
        $y = $ey[$i];
        eval($eval);
        $k1 = $result;
        $x = $ex[$i] + (0.5*$h);
        $y = $ey[$i] + (0.5*$h*$k1);
        eval($eval);
        $k2 = $result;
        $x = $ex[$i] + (0.5*$h);
        $y = $ey[$i] + (0.5*$h*$k2);
        eval($eval);
        $k3 = $result;
        $x = $ex[$i] + $h;
        $y = $ey[$i] + ($h*$k3);
        eval($eval);
        $k4 = $result;
        $ey[$i+1] = $ey[$i] + (($h/6)* ($k1 + 2*$k2 + 2*$k3 + $k4));
        $ex[$i+1] = $int1 + ($h*($i+1));
   		echo "\n<p>y(".$ex[$i+1].") = ".$ey[$i+1]."</p>";
	}
?>
